﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using DB.Model;

namespace HR_ASP.ViewModel
{
    public class ObecnoscViewModel
    {
        public int ID { get; set; }
        public int IDPracow { get; set; }
        public DateTime DataRoz { get; set; }
        public DateTime DataZak { get; set; }
        public DateTime DataM { get; set; }

        public ObecnoscViewModel()
        {
        }

        public ObecnoscViewModel(Obecnosc obecnosc)
        {
            this.ID = obecnosc.ID_Obec;
            this.IDPracow = (int)obecnosc.ID_Pracow;
            this.DataRoz = (DateTime)obecnosc.Data_Rozp;
            this.DataZak = (DateTime)obecnosc.DataK_Zakon;
            this.DataM = (DateTime)obecnosc.DataM;
        }

        public Obecnosc getModel(Obecnosc obecnosc)
        {
            obecnosc.ID_Obec = this.ID;
            obecnosc.ID_Pracow = this.IDPracow;
            obecnosc.Data_Rozp = this.ID == 0 ? DateTime.Now : this.DataRoz;
            if (this.ID != 0)
            {
                obecnosc.DataK_Zakon = DateTime.Now;
            }

            return obecnosc;
        }
    }

}